<template>
    <div class="table-header-wrap">
        <div class="table-header-title">
            <span>查询模版：</span>
        </div>
        <div>
            <qt-button button-name="刷新" icon="el-icon-refresh" @click="refresh" />
            <template v-for="(item,index) in buttons">
                <qt-button
                    v-if="item.visible"
                    :button-name="item.name"
                    :icon="item.prefixIcon"
                    :key="index"
                    :disabled="item.disabled"
                    @click="_.isFunction(item.callback) ? item.callback() : null"
                />
            </template>
            <qt-button button-name="编辑列" icon="el-icon-setting" @click="setting" />
        </div>
        <el-dialog :append-to-body="true" :visible.sync="showDialog" :lock-scroll="false">
            <table-diy />
        </el-dialog>
    </div>
</template>

<script>
export default {
    name: 'qtPageHeader',

    data() {
        return {
            showDialog: true
        };
    },

    inject: ['$list'],

    props: {
        buttons: {
            type: Array,
            default() {
                return [];
            }
        }
    },

    methods: {
        refresh() {
            this.$list.$refs.table.refresh();
        },

        setting() {
            this.showDialog = true;
        }
    }
};
</script>

<style lang="scss" scoped>
.table-header-wrap {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .table-header-title {
        font-size: 14px;
        color: #000;
    }
}
</style>
